package com.gpjcjl.database;

import androidx.room.Room;

import com.gpjcjl.App;

public class DbHelper {

    private static DbHelper instance;
    private AppDatabase db;

    public static DbHelper getInstance() {
        if (instance == null) {
            synchronized (DbHelper.class) {
                if (instance == null) {
                    instance = new DbHelper();
                }
            }
        }
        return instance;
    }

    private DbHelper() {
        db = Room.databaseBuilder(App.getInstance(),
                AppDatabase.class, "cmcheck")
                .allowMainThreadQueries()//允许在主线程中查询
                .build();
    }

    public AppDatabase getDataBase() {
        return db;
    }
}
